package com.back.campus_back.controller;


import com.back.campus_back.domain.Goods;
import com.back.campus_back.service.impl.CollectServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 */
@RestController
@RequestMapping("/collect")
@Api(tags = "收藏商品的控制类")
public class CollectController {
    @Autowired
    CollectServiceImpl collectService;

    //查看收藏商品的信息
    @ApiOperation("根据用户id查看收藏商品的信息")
    @GetMapping("/findAllCollect/{u_id}")
    public List<Goods> findAllCollect(@PathVariable(value = "u_id")int u_id){
        return collectService.findAllCollect(u_id);
    }


    //个人添加收藏商品
    @ApiOperation("用户添加收藏商品")
    @GetMapping("/addCollect/{u_id}/{g_id}")
    public String collectGoods(@PathVariable(value = "u_id")int u_id,@PathVariable(value = "g_id")int g_id){
        return collectService.collectGoods(u_id,g_id);
    }


    //个人删除收藏商品
    @ApiOperation("用户取消收藏商品")
    @GetMapping("/cancelCollect/{u_id}/{g_id}")
    public String cancelCollect(@PathVariable(value = "u_id")int u_id,@PathVariable(value = "g_id")int g_id){
        return collectService.cancelCollect(u_id,g_id);
    }


}

